import { http } from '@/utils/request'
import { getRefreshToken } from '@/utils/storage'
import { loginTS, LoginType, verificationTS } from './type'

//无感刷新token
export const getNewToken = (): Promise<unknown> => {
    return http.post(
        '/user/get_new_token',
        {},
        {
            headers: {
                Authorization: `Bearer ${getRefreshToken()}`
            }
        }
    )
}

//登录
export const getUserLogin = (data: loginTS) => {
    return http.post<LoginType>('/user/login', data)
}

//获取验证码
export const getVerifyCode = (data: { username: string }) => {
    return http.post<LoginType>('/user/get_verify_code', data)
}

//获取验证码
export const getCaptchaLogin = (data: verificationTS) => {
    return http.post<LoginType>('/user/verify', data)
}

//退出登录
export const getQuitLogin = (data: { refresh_token: string }) => {
    return http.post('/user/logout', data)
}

//获取菜单权限
export const getPermissionsList = () => {
    return http.post('/user/get_permissions')
}

//阅读
export const reading = (data: { is_flag: boolean, username: string }) => {
    return http.post('/user/informed_consent_record', data)
}

